package com.happyrecyclingstation.controller.jobseeker;

import com.happyrecyclingstation.dto.PosJobSeekerQueryDto;
import com.happyrecyclingstation.service.PositionService;
import com.happyrecyclingstation.utils.Result;
import com.happyrecyclingstation.vo.PageResult;
import com.happyrecyclingstation.vo.JobSeekerPositionVO;
import com.happyrecyclingstation.vo.PosDetailVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 求职者
 */
@Slf4j
@RestController("jobSeekerPositionController")
@RequestMapping("/jobSeeker/positions")
public class PositionController {
    @Autowired
    private PositionService positionService;

    /**
     * 首页职位列表
     * @return
     */
    @GetMapping("/index")
    public Result getPositions() {
        log.info("获取首页职位列表");
        List<JobSeekerPositionVO> posList = positionService.getPositions();
        return Result.success(posList);
    }

    /**
     * 求职者条件分页查询职位列表
     */
    @GetMapping
    public Result getPositionsByCondition(PosJobSeekerQueryDto posQueryParam) {
        log.info("条件分页查询职位列表:{}", posQueryParam);
        PageResult<JobSeekerPositionVO> pageResult = positionService.getList(posQueryParam);
        return Result.success(pageResult);
    }

    /**
     * 获取职位详情
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public Result getPosById(@PathVariable("id") Integer id) {
        log.info("获取职位详情:{}", id);
        PosDetailVO posDetailVo = positionService.getPosById(id);
        return Result.success(posDetailVo);
    }
}
